﻿using System;

namespace _02_FactoryMethod
{
    class Program
    {
        static void Main(string[] args)
        {
            //初始化两个工厂类
            Creator madePhone47Factory = new MadePhone47Factory();
            Creator madePhone50Factory = new MadePhone50Factory();
            //制造手机
            madePhone47Factory.MadePhoneFactory().Made();
            madePhone50Factory.MadePhoneFactory().Made();
            Console.ReadKey();
        }
    }
    //手机的接口
    public interface Phone
    {
        void Made();
    }
    public class MadePhone47 : Phone
    {
        public void Made()
        {
            Console.WriteLine("4.7英寸手机做好了");
        }
    }
    public class MadePhone50 : Phone
    {
        public void Made()
        {
            Console.WriteLine("5.0英寸手机做好了");
        }
    }
    public interface Creator
    {
        Phone MadePhoneFactory();
    }

    //制造4.7英寸的手机的工厂类
    public class MadePhone47Factory : Creator
    {
        public Phone MadePhoneFactory()
        {
            return new MadePhone47();
        }
    }
    //制造5.0英寸的手机的工厂类
    public class MadePhone50Factory : Creator
    {
        public Phone MadePhoneFactory()
        {
            return new MadePhone50();
        }
    }
}
